package net.csdra.libraryborrowing.service.book;

import net.csdra.libraryborrowing.domain.book.BookOrder;
import net.csdra.libraryborrowing.domain.user.UserAuthoriry;
import org.springframework.security.access.prepost.PreAuthorize;

import java.util.List;

/**
 * Created by msf on 2017/10/12.
 */
@PreAuthorize("hasRole('" + UserAuthoriry.USER_AUTHORIRY_MANGE + "')")
public interface BookOrderManageService {

    /**
     * 馆内人员处理订单
     * 输入参数handleState的值必须为ACCEPT或REJECT，
     * 订单的当前状态必须为WAITACCEPT
     * 将订单状态修改为handleState的值（handleState的值必须为ACCEPT和REJECT）
     * 创建BookOrderLog
     *
     * @param handleBookOrder
     * @return
     */
    public BookOrder handleBookOrder(HandleBookOrder handleBookOrder);

    /**
     * 配送订单
     * 1，将订单状态修改为DISTRIBUTION，BookOrder的当前状态必须为ACCEPT,并设置发货人信息（senderUserId为当前操作用户）。
     * 2，通过ems接口获取快递编号     *
     * 3，为订单内的每一个副本创建UserBoorrow和UserBoorwLog,metaId为BookOrder的consigneeUserId，修改对应副本状态为快递中，UserBoorrow的state设置为BORROWING*
     * 4，创建一个BookOrderLog对象（begin为系统当前时间）,
     *
     * @param distributionBookOrder
     * @return
     */
    public BookOrder distributionBookOrder(DistributionBookOrder distributionBookOrder);


    class DistributionBookOrder {
        String bookOrderId;
        String remark;
        List<String> bookCopyIds;

        public String getBookOrderId() {
            return bookOrderId;
        }

        public void setBookOrderId(String bookOrderId) {
            this.bookOrderId = bookOrderId;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }

        public List<String> getBookCopyIds() {
            return bookCopyIds;
        }

        public void setBookCopyIds(List<String> bookCopyIds) {
            this.bookCopyIds = bookCopyIds;
        }

        public String getSenderShippingAddressId() {
            return senderShippingAddressId;
        }

        public void setSenderShippingAddressId(String senderShippingAddressId) {
            this.senderShippingAddressId = senderShippingAddressId;
        }

        //发货人地址信息
        String senderShippingAddressId;
    }

    class HandleBookOrder {
        String bookOrderId;
        String handleState;
        String remark;

        public String getHandleState() {
            return handleState;
        }

        public void setHandleState(String handleState) {
            this.handleState = handleState;
        }

        public String getBookOrderId() {
            return bookOrderId;
        }

        public void setBookOrderId(String bookOrderId) {
            this.bookOrderId = bookOrderId;
        }

        public String getRemark() {
            return remark;
        }

        public void setRemark(String remark) {
            this.remark = remark;
        }
    }
}
